<?php
/**
 * Service of Department
 *
 * @author fsqijy
 */

require_once BaseUtil::getModulePath("base")  .  '/services/BaseService.php';
require_once BaseUtil::getModulePath("department")  .  '/models/DepartmentDao.php';

class DepartmentService extends BaseService {

	protected $departmentDao;

	public function __construct ()
	{
		parent::__construct();
		$this->departmentDao = new DepartmentDao();
		$this->departmentDao->setDb($this->db);
	}

	public function saveDepartment($department = array()){
		if(!empty ($department)){
			$this->departmentDao->insert($department);
		}
	}
    
	public function getAllDepartment($where=null){

		$result=$this->departmentDao->fetchAll($where);
		return $result;
	}
	public function getDepartmentByID($id){
        $result = $this->departmentDao->getDepartmentById($id);
		return $result;
	}
	public function updateDepartment($id,$set){
		if(!empty ($set)){
			$this->departmentDao->updateDepartment($id,$set);
		}
	}
	public function deleteDepartment($id){
		if(!empty ($id)){
			$this->departmentDao->deleteDepartment($id);
		}
	}

    public function deleteAllDepartments($ids){
        foreach($ids as $id){
            if(!empty($id)){
                $this->departmentDao->deleteDepartment($id);
            }
        }
    }
}

?>
